<?php
class EmployeesController {
	public function lists (){
		$employees = HttpServerManager::getEmployeesServer();
		$data = $employees->pagingBySearch($_GET);
		
		$department = Common::_t('department');
		$status = Common::_t('employees_status');
		$type = Common::_t('employees_type');
		$data['departmentOptions'] = $department;
		$data['statusOptions'] = $status;
		$data['typeOptions'] = $type;
		return $data;
	}
	public function add(){
		$data = array();
		if (!empty($_GET['id'])){
			$data = HttpDaoManager::getEmployeesDao()->get($_GET['id']);
		}
		$type = Common::_t('employees_type');
		$data['typeOptions'] = page_modifier_options($type,Common::getStrValue($data,'type'));
		$department = Common::_t('department');
		$data['departmentOptions'] = page_modifier_options($department,Common::getStrValue($data,'department'));
		$position = Common::_t('position');
		$data['positionOptions'] = page_modifier_options($position,Common::getStrValue($data,'position'));
		$status = Common::_t('employees_status');
		$data['statusOptions'] = page_modifier_options($status,Common::getStrValue($data,'status'));
		$nationality = Common::_t('nationality');
		$data['nationalityOptions'] = page_modifier_options($nationality,Common::getStrValue($data,'nationality'));
		
		$data['id'] = isset($data['id'])?$data['id']: Common::getGetStrValue('id');
		return $data;
	}
	public function subAdd(){
		 HttpServerManager::getEmployeesServer()->add($_POST);
		ClassManager::getToos()->msgbox('添加成功');
	}
	public function subUpdate(){
		HttpServerManager::getEmployeesServer()->update($_POST, $_POST['id']);
		ClassManager::getToos()->msgbox('修改成功','employees_lists.html');
	}
	public function delete(){
		HttpServerManager::getEmployeesServer()->deleteBatchByid($_GET['id']);
		ClassManager::getToos()->msgbox("删除成功");
	}
}
?>